import cv2 as cv
import numpy as np


def main():
    img = cv.imread('../data/j.png', 0)
    kernel = np.ones((5, 5), np.uint8)
    gradient = cv.morphologyEx(img, cv.MORPH_GRADIENT, kernel)
    erosion = cv.erode(img, kernel, iterations=1)
    dilation = cv.dilate(img, kernel, iterations=1)
    dme = dilation - erosion
    res = np.hstack((img, gradient, dme))
    cv.imshow('Press any key to exit', res)
    cv.waitKey(0)
    cv.destroyAllWindows()


if __name__ == "__main__":
    main()
